import Vue from 'vue'
import Router from 'vue-router'
import index from './views/index.vue'
import upload from './views/upload.vue'
import loading from './views/loading.vue'
import confirm from './views/confirm.vue'
import result from './views/result.vue'
import errors from './views/errors.vue'

Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      redirect: {
        name: 'index'
      }
    },
    {
      // 海报页
      path: '/index',
      name: 'index',
      component: index
    },
    {
      // 上传页
      path: '/upload',
      name: 'upload',
      component: upload
    },
    {
      // 加载页
      path: '/loading',
      name: 'loading',
      component: loading
    },
    {
      // 确认页
      path: '/confirm',
      name: 'confirm',
      component: confirm,
      meta: {
        needResult: true
      }
    },
    {
      // 结果页
      path: '/result',
      name: 'result',
      component: result,
      meta: {
        needResult: true
      }
    },
    {
      // 错误页
      path: '/errors',
      name: 'errors',
      component: errors
    }
  ]
})

router.beforeEach((to, from, next) => {
  next()
})

export default router
